package cn.cuilan.strategy;

import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy;

/**
 * 数据库表命名策略
 * 使Hibernate在进行数据库表操作时加上默认前缀:  t_
 *
 * @author zhang.yan
 */
public class TableNamePrefixStrategy extends SpringPhysicalNamingStrategy {

    @Override
    public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) {
        Identifier newName = new Identifier("t_" + name.getText(), name.isQuoted());
        return super.toPhysicalTableName(newName, jdbcEnvironment);
    }
}
